<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8" />
		<meta name="viewport" content="width=device-width,initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no" />
		<title>设备管理</title>
		<link href="css/new_file.css" rel="stylesheet" type="text/css">
		<link href="css/mui.min.css" rel="stylesheet" type="text/css">
		<script src="js/jquery-1.8.3.min.js"></script>
		<script charset="UTF-8" src="js/config.js"></script>
		<script charset="UTF-8" src="js/testActivityName.js"></script>
		<script charset="UTF-8" src="js/core.js"></script>
		<script charset="UTF-8" src="js/cipher-core.js"></script>
		<script charset="UTF-8" src="js/tripledes.js"></script>
		<script charset="UTF-8" src="js/mode-ecb.js"></script>
		<script type="text/javascript" src="js/zepto.min.js"></script>
		<script type="text/javascript" src="js/spin.min.js"></script>
		<script charset="UTF-8" src="js/mui.min.js"></script>
		<script src="js/echarts.min.js"></script>
	</head>
	<body>
		<div class="head-zhjf">
			<img src="images/fanhui@3x.png" class="ryjk-tx" onclick="addReturn()">
			<p style="color: white;size: 16px;">设备管理</p>
		</div>
		<form  id="form1" target="ifr">
		<div class="moban-lb">
			<div class="moban-lb-l">
				<div class="ziduan-mb">设备类型</div>
			</div>
			<div class="moban-lb-r">
				<select id="noApplicationRecord" required>
				</select>
			</div>
			<div class="clear"></div>
		</div>
		<div class="moban-lb">
			<div class="moban-lb-l">
				<div class="ziduan-mb">设备序列号</div>
			</div>
			<div class="moban-lb-r">
				<input id="deviceSN" type="text" placeholder="请输入" onfocus="if(value==defaultValue){value='';this.style.color='#616573'}" onblur="if(!value){value=defaultValue;this.style.color='#dee3f0'}" style="color:#cdcdcd;" class="shuru-jine" required>
			</div>
			<div class="clear"></div>
		</div>
		<div id="equipment"></div>
		<div id="equipment1"></div>
		<div class="moban-lb">
			<div class="moban-lb-l">
				<div class="ziduan-mb">状态</div>
			</div>
			<div class="moban-lb-r">
				<select id="deviceStatusID" required>
				</select>
			</div>
			<div class="clear"></div>
		</div>
		<div class="tijiao">
			<input type="submit" class="tijiao-btn" value="提交">
		</div>
		</form>
		<iframe name='ifr' id="ifr" style='display: none;'></iframe><!--表单提交防止刷新-->
		<!--封装同步异步请求-->
		<script  charset="UTF-8" src="js/simple.tool.js" ></script>
		<script>
			$("#form1").submit(function () {
				var map={};
				map.url="saveDevice";
				map.devicetypeId=$("#noApplicationRecord").val();
				map.deviceSerial=$("#deviceSN").val();
				var statusWorktemp=$("#deviceStatusID").val();
				if (statusWorktemp=='1'){
					map.statusWork='00A';
				} else if (statusWorktemp=='0') {
					map.statusWork='00X';
				}
				map.col2=$("#equipment14").val();
				map.ip=$("#equipment11").val();
				map.port=$("#equipment12").val();
				ajaxRequestPostEDS(function (data) {
					equipments();
				},map)
			});
			var deviceStatusData = JSON.parse(localStorage.getItem('deviceStatusData'));
			var deviceTypeData = JSON.parse(localStorage.getItem('deviceTypeData'));
			var noApplicationRecord = document.getElementById('noApplicationRecord');
			var deviceStatusID = document.getElementById('deviceStatusID');
			var equipment = document.getElementById('equipment');
			var equipment1 = document.getElementById('equipment1');
			var equipmentArr = [{
				"name":"设备IP"
			}];
			var equipmentArr1 = [{
				"name":"设备端口号"
			}];
			function setDiv(item) {
				var div = '<option value="' + item.deviceTypeID + '"   id="' + item.deviceTypeID + '" >' +
					item.deviceType +
					'</option>'
				return div
			}

			function setDiv1(item) {
				var div = '<option  value="' + item.statusID + '" id="' + item.statusID + '">' +
					item.status +
					'</option>'
				return div
			}

			function getnoApplicationData() {
				var html = ''
				for(var i = 0; i < deviceTypeData.length; i++) {
					html += setDiv(deviceTypeData[i])
				}
				noApplicationRecord.innerHTML = html
			}

			function getnoApplicationData1() {
				var html = ''
				for(var i = 0; i < deviceStatusData.length; i++) {
					html += setDiv1(deviceStatusData[i])
				}
				deviceStatusID.innerHTML = html
			}
			window.onload = getnoApplicationData()
			window.onload = getnoApplicationData1()
			
			
			
				function setDiv2(item) {
						var div = '<div class="moban-lb"><div class="moban-lb-l"><div class="ziduan-mb">设备RFID号</div></div><div class="moban-lb-r"><input  required  id="equipment13" type="text" placeholder="请输入" onfocus="if(value==defaultValue)" onblur="if(!value){value=defaultValue;}" style="" class="shuru-jine"></div><div class="clear"></div></div>'
						return div
					}
					function getnoApplicationData2() {
						var html = ''
						for(var i = 0; i < equipmentArr.length; i++) {
							html += setDiv2(equipmentArr[i])
						}
						equipment.innerHTML = html
					}
					function setDiv3(item) {
						var div = '<div class="moban-lb"><div class="moban-lb-l"><div class="ziduan-mb">设备编号</div></div><div class="moban-lb-r"><input required id="equipment14" type="text" placeholder="请输入" onfocus="if(value==defaultValue)" onblur="if(!value){value=defaultValue;}" style="" class="shuru-jine"></div><div class="clear"></div></div>';
						return div
					}
					function getnoApplicationData3() {
						var html = ''
						for(var i = 0; i < equipmentArr1.length; i++) {
							html += setDiv3(equipmentArr1[i])
						}
						equipment1.innerHTML = html
					}
					window.onload = getnoApplicationData2()
					window.onload = getnoApplicationData3()
			
			
			$("#noApplicationRecord").change(function() {
				var str = $(this).children('option:selected').val();
				//			alert($(this).children('option:selected').val());
				if(str == 'RFID阅读器') {
					function setDiv2(item) {
						var div = '<div class="moban-lb"><div class="moban-lb-l"><div class="ziduan-mb">设备IP</div></div><div class="moban-lb-r"><input id="equipment11" type="text" placeholder="请输入" onfocus="if(value==defaultValue)" onblur="if(!value){value=defaultValue;}" style="" class="shuru-jine"></div><div class="clear"></div></div>'
						return div
					}
					function getnoApplicationData2() {
						var html = ''
						for(var i = 0; i < equipmentArr.length; i++) {
							html += setDiv2(equipmentArr[i])
						}
						equipment.innerHTML = html
					}
					function setDiv3(item) {
						var div = '<div class="moban-lb"><div class="moban-lb-l"><div class="ziduan-mb">设备端口号</div></div><div class="moban-lb-r"><input id="equipment12" type="text" placeholder="请输入" onfocus="if(value==defaultValue)" onblur="if(!value){value=defaultValue;}" style="" class="shuru-jine"></div><div class="clear"></div></div>'
						return div
					}
					function getnoApplicationData3() {
						var html = ''
						for(var i = 0; i < equipmentArr1.length; i++) {
							html += setDiv3(equipmentArr1[i])
						}
						equipment1.innerHTML = html
					}
					window.onload = getnoApplicationData2()
					window.onload = getnoApplicationData3()
					
				}else{
					function setDiv2(item) {
						var div = '<div class="moban-lb"><div class="moban-lb-l"><div class="ziduan-mb">设备RFID号</div></div><div class="moban-lb-r"><input id="equipment13" type="text" placeholder="请输入" onfocus="if(value==defaultValue)" onblur="if(!value){value=defaultValue;}" style="" class="shuru-jine"></div><div class="clear"></div></div>'
						return div
					}
					function getnoApplicationData2() {
						var html = ''
						for(var i = 0; i < equipmentArr.length; i++) {
							html += setDiv2(equipmentArr[i])
						}
						equipment.innerHTML = html
					}
					function setDiv3(item) {
						var div = '<div class="moban-lb"><div class="moban-lb-l"><div class="ziduan-mb">设备编号</div></div><div class="moban-lb-r"><input id="equipment14" type="text" placeholder="请输入" onfocus="if(value==defaultValue)" onblur="if(!value){value=defaultValue;}" style="" class="shuru-jine"></div><div class="clear"></div></div>';
						return div
					}
					function getnoApplicationData3() {
						var html = ''
						for(var i = 0; i < equipmentArr1.length; i++) {
							html += setDiv3(equipmentArr1[i])
						}
						equipment1.innerHTML = html
					}
					window.onload = getnoApplicationData2()
					window.onload = getnoApplicationData3()
				}
			})
		</script>

	</body>

</html>